package cn.aylog.test;

import com.alibaba.fastjson.JSONObject;

import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.URL;
import java.net.URLConnection;

public class HttpDemo {
    public static void main(String[] args) throws Exception {
        URL url = new URL("http://localhost:8080/test");
        URLConnection conn = url.openConnection();
        conn.connect();
        InputStream is = conn.getInputStream();
        byte[] content = new byte[1024];
        int len = 0;
        while( (len = is.read(content)) != -1 ) {
            String str = new String(content, 0, len);
            JSONObject object = JSONObject.parseObject(str);
            Object name = object.get("name");
            System.out.println(name);
        }
        is.close();
    }
}
